package com.oilsoft.module.main.ui.presenters
{
	import com.oilsoft.shared.events.LoginEvent;
	import com.oilsoft.shared.constant.LoginConstant;
	import com.oilsoft.shared.vos.User;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;

	public class LoginModel extends EventDispatcher
	{
		// -------------------------------------------------------
		// Contructor
		// -------------------------------------------------------
		
		private var dispatcher:IEventDispatcher;
		
		
		public function LoginModel( dispatcher:IEventDispatcher )
		{
			this.dispatcher = dispatcher;
		}
		
		
		private var _loginState:String=LoginConstant.DEFAULT;
		[Bindable(Event="loginStateChange")]
		public function get loginState():String
		{
			return _loginState;
		}

		public function set loginState(value:String):void
		{
			_loginState = value;
			dispatchEvent( new Event( "loginStateChange" ) );
		}

		public function login(username:String,password:String):void{
			var user:User = new User();
			user.username=username;
			user.password=password;
			var event:LoginEvent = new LoginEvent(LoginEvent.LOGIN);
			event.user=user;
			dispatcher.dispatchEvent(event);
		}
	}
}